import sys
import zmq

if len(sys.argv) < 2:
    print("I: Syntax: %s <endpoint>" % sys.args[0])
    sys.exit(0)

endpoint = sys.argv[1]
context = zmq.Context()
server = context.socket(zmq.REP)
server.bind(endpoint)

print("I: Service is ready at %s" % endpoint)
while True:
    request = server.recv_multipart()
    if not request:
        break
    assert len(request) == 2
    address = request[0]
    reply = [address, b"OK"]
    server.send_multipart(reply)

server.setsockopt(zmq.LINGER, 0)